package cn.qihang.ssm.service.impl;

import cn.qihang.ssm.mapper.MemberMapper;
import cn.qihang.ssm.mapper.OrdersMapper;
import cn.qihang.ssm.mapper.ProductMapper;
import cn.qihang.ssm.pojo.Member;
import cn.qihang.ssm.pojo.Orders;
import cn.qihang.ssm.pojo.Product;
import cn.qihang.ssm.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: qihang
 * @Date: 2022/11/1 14:57
 * @Desc:
 */
@Service
public class OrdersServiceImpl implements OrdersService {

    @Autowired
    private OrdersMapper ordersMapper;

    /**
     * 查询所有订单
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<Orders> findAll(Integer page, Integer size) {
        return this.ordersMapper.findAll();
    }


    /**
     * 订单详情
     * @param id
     * @return
     */
    @Override
    public Orders findById(Integer id) {
        return this.ordersMapper.findById(id);
    }


    /**
     * 新增订单
     * @param order
     */
    @Override
    public void save(Orders order) {
        //向orders表中添加信息
        this.ordersMapper.save(order);

        //向order_traveller添加游客关联信息
        // this.ordersMapper.save_order_traveller(order);
    }

    /**
     * 修改订单
     * @param orders
     */
    @Override
    public void edit(Orders orders) {
        this.ordersMapper.edit(orders);
    }

    /**
     * 删除订单
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        //删除order_traveller表中的关联关系
        this.ordersMapper.delete_order_travellerById(id);

        //删除orders中的订单
        this.ordersMapper.deleteById(id);
    }

}
